﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProjectFinal {
	public class Date {
		private DateTime _date;	//Object containing the date

		//Date constructor
		//param:	month, day, year
		//notes:	in the name of intuitivity, the parameter order suffers from a United States bias
		//				and yes, I know "intuitivity" is not a word, but you can guess what it means. :)
		public Date(int month, int day, int year) {
			_date = new DateTime(year, month, day, new System.Globalization.GregorianCalendar());
		}//Date(int, int, int)

		//Date constructor
		//param:	DateTime object
		//notes:	provided so the assignment operators are easier to read
		public Date(DateTime d) {
			_date = new DateTime();
			_date = d;
		}//Date(DateTime)

		//Date constructor
		//param:	string representing date 
		public Date(string d) {
			_date = new DateTime();
			_date = DateTime.ParseExact(d, Constants.DATE_FORMAT, null);
		}//Date(string)

		//Return the date object
		public DateTime getDate() { return _date; }

		//Return the date as a string
		override public string ToString() { return _date.ToString(Constants.DATE_FORMAT, null); }
		
		//Move/reassign current date to the next day
		public void beTomorrow() { _date = _date.AddDays(1); }

		//Add a specified number of days to the current date
		//param:	number of days to add
		//post:		returns a new Date object (does not change current Date object)
		public Date AddDays(double d) { return new Date(this._date.AddDays(d)); }

		//Comparison operators
		static public bool operator <(Date ls, Date rs) { return ls._date < rs._date; }
		static public bool operator <=(Date ls, Date rs) { return ls._date <= rs._date; }
		static public bool operator >(Date ls, Date rs) { return ls._date > rs._date; }
		static public bool operator >=(Date ls, Date rs) { return ls._date >= rs._date; }
		//Arithmetic operators (to add or subtract days)
		static public Date operator +(Date ls, int rs) { return ls.AddDays(rs); }
		static public Date operator -(Date ls, int rs) { return ls.AddDays(-rs); }
	}//class Date
}//namespace
